package com.dragon.modules.yuegou.service.wallet;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.dragon.common.web.PageRequest;
import com.dragon.modules.yuegou.entity.wallet.MerchantTradeEntity;
import com.dragon.modules.yuegou.enums.CurrencyType;
import com.dragon.modules.yuegou.enums.wallet.MerchantTradeType;
import com.dragon.modules.yuegou.model.system.Document;
import com.dragon.modules.yuegou.model.wallet.EntityCardRecord;
import com.dragon.modules.yuegou.model.wallet.MemberCard;
import com.dragon.modules.yuegou.model.wallet.MerchantStatistics;
import com.dragon.modules.yuegou.model.wallet.MerchantTrade;
import com.dragon.modules.yuegou.model.wallet.MerchantWallet;
import com.dragon.modules.yuegou.query.wallet.MerchantTradeQuery;
import com.dragon.modules.yuegou.query.wallet.TradeDetailQuery;

import java.math.BigDecimal;
import java.util.List;
/**
 * 商户交易（在商户角度的交易流水） 服务接口
 *
 * @author pbuilder generated
 * @date 2019-06-03 15:20:36
 * @version 2.0
 */
public interface MerchantTradeService extends IService<MerchantTradeEntity> {

	public BigDecimal getIncomeAmount(MerchantTradeQuery query);
	
    /**
     * 商户账户明细
     * @param page
     * @param busdId
     * @param walletId
     * @param merchantName
     * @param type
     * @param tradeDetailQuery
     * @return
     */
    IPage<MerchantTrade> tradeDetail(PageRequest page, String busdId, String walletId, String merchantName, String type,String described, TradeDetailQuery tradeDetailQuery);

    /**
     * 商户账户总入账支出
     * @param busdId
     * @param walletId
     * @param merchantName
     * @param type
     * @param tradeDetailQuery
     * @return
     */
    MerchantTrade tradeTotal(String busdId, String walletId, String merchantName, String type,String described, TradeDetailQuery tradeDetailQuery);

    /**
     * 商户悦币收入流水
     * */
	IPage<MerchantTrade> coinIncome(PageRequest page,MerchantTradeQuery query);

	/**
     * 商户现金收入流水
     * */
	IPage<MerchantTrade> cashIncome(PageRequest page,MerchantTradeQuery query);

	/**
	 * 商户悦卡收入流水
	 * */
	IPage<MerchantTrade> cardIncome(PageRequest page,MerchantTradeQuery query);

	/**
	 * 保存交易记录
	 * @param memberCard
	 * @param orderNo
	 * @param amount
	 */
	void saveTrade(String memberId, MerchantWallet merchantWallet, MemberCard memberCard, String orderNo, String goodsId, BigDecimal amount, CurrencyType currencyType, MerchantTradeType tradeType);


	/**
	 * 保存实体卡交易记录
	 * @param memberCard
	 * @param orderNo
	 * @param amount
	 */
	void saveTrade(String memberId, MerchantWallet merchantWallet, MemberCard memberCard, String orderNo, String goodsId, BigDecimal amount, CurrencyType currencyType, MerchantTradeType tradeType, EntityCardRecord entityCardRecord);
	
	
	/**
	 * 保存交易记录(结算价)
	 * @param memberCard
	 * @param orderNo
	 * @param amount
	 */
	void saveTradesSettlement(String memberId, MerchantWallet merchantWallet, MemberCard memberCard, String orderNo, BigDecimal amount, CurrencyType currencyType, MerchantTradeType tradeType,BigDecimal settlementPrice,String goodsId);

	
	/**
	 * 统计今日收入
	 * @param merchantId
	 * @return
	 */
	BigDecimal totalTodayIncome(String merchantId);

	/**
	 * 开发票
	 * @param countTime
	 */
    void merchantInvoice(String countTime,String miniTime);

    /**
     * 获取商户月收入统计
     * */
	MerchantStatistics statistics(String merchantId, String yearMonth);

	/**
	 * 保存运费记录
	 * @param merchantId
	 * @param orderNo
	 * @param freight
	 */
	void saveFreightTrade(String merchantId, String orderNo, BigDecimal freight, CurrencyType currencyType);

	/**
	 * 根据单品id查询商户记录
	 * @param goodId
	 * @return
	 */
    List<MerchantTrade> selectByGoodsId(String goodId);

	/**
	 * 悦卡开发票结算
	 * @param merchantId
	 * @param amountBefore
	 * @param amountAfter
	 */
	void saveInvoiceTrade(String merchantId, BigDecimal amountBefore,BigDecimal amountAfter);

	/**
	 * 统计商户某时间节点之后的商户账余额
	 * @param countTime
	 * @param yueCardCountTime
	 */
    void merchantTradeWallet(String countTime,String yueCardCountTime);

	/**
	 * 商户账户明细
	 * @param page
	 * @param busdId
	 * @param walletId
	 * @param merchantName
	 * @param type
	 * @param orderType
	 * @param payType
	 * @param processState
	 * @param tradeDetailQuery
	 * @return
	 */
    IPage<MerchantTrade> merchantTradeDetail(PageRequest page, String busdId, String walletId, String merchantName, String type, String orderType, String payType, String processState, TradeDetailQuery tradeDetailQuery);

	/**
	 * 商户账户明细 统计
	 * @param busdId
	 * @param walletId
	 * @param merchantName
	 * @param type
	 * @param orderType
	 * @param payType
	 * @param processState
	 * @param tradeDetailQuery
	 * @return
			 */
	MerchantTrade merchantTradeTotal(String busdId, String walletId, String merchantName, String type, String orderType, String payType, String processState, TradeDetailQuery tradeDetailQuery);

	/**
	 * 查询需要开发票的数据
	 * @param merchantTrade
	 * @return
	 */
	List<MerchantTrade> merchantInvoiceList(MerchantTrade merchantTrade);
	
	/**
	 * 导出账户明细
	 * @param busdId
	 * @param walletId
	 * @param merchantName
	 * @param type
	 * @param orderType
	 * @param processState
	 * @param tradeDetailQuery
	 * @return
	 */
	Document exportTradeDetail(PageRequest page, String busdId, String walletId, String merchantName, String type, String orderType, String payType, String processState, TradeDetailQuery tradeDetailQuery);
}